home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / gfx / 3d / irit50src.lha / irit5 / bool_lib / bool_loc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-30  |  4.9 KB  |  106 lines

  1. /*****************************************************************************
  2. *   "Irit" - the 3d (not only polygonal) solid modeller.             *
  3. *                                         *
  4. * Written by:  Gershon Elber                Ver 0.2, Mar. 1990   *
  5. ******************************************************************************
  6. *   Definitions, local to modules, of Boolean operation modules:         *
  7. *****************************************************************************/
  8.  
  9. #ifndef BOOL_LOC_H
  10. #define BOOL_LOC_H
  11.  
  12. #include "bool_lib.h"
  13.  
  14. /*   The following structure is used to keep the intersecting segments of    */
  15. /* each polygons, which the other object polygons. they are saved as a       */
  16. /* list of segments, which can form a closed loop (if totally internal) or   */
  17. /* an open one (in which the two ends intersects the polygon boundaries).    */
  18. /*   Note all the polygons of the two given objects must be convex!         */
  19. typedef struct InterSegmentStruct {
  20.     PointType PtSeg[2];               /* The two end points of the segment. */
  21.     /* If intersect polygon vertex, point on it. If internal to poly, NULL.  */
  22.     IPVertexStruct *V[2];
  23.     IPPolygonStruct *Pl;           /* Point on the (other) intersecting polygon. */
  24.     struct InterSegmentStruct *Pnext;
  25. } InterSegmentStruct;
  26.  
  27. /* Used to hold list of InterSegment polylines: */
  28. typedef struct InterSegListStruct {
  29.     InterSegmentStruct *PISeg,          /* Point to InterSegment Polyline. */
  30.     *PISegMaxX;               /* Used in closed loops handling. */
  31.     struct InterSegListStruct *Pnext;          /* Point to next polyline. */
  32. } InterSegListStruct;
  33.  
  34. /* Used in sorting of open loops: */
  35. typedef struct SortOpenStruct {
  36.     RealType Key;
  37.     InterSegListStruct *PLSeg;        /* Point to open loop with this key. */
  38.     struct SortOpenStruct *Pnext;           /* Point to next in list. */
  39. } SortOpenStruct;
  40.  
  41. /* The following are temporary flags used to mark the original vertices in   */
  42. /* the resulting object. Used to detected edges originated in the input         */
  43. /* object, and used to propagate the adjacencies.                 */
  44. #define ORIGINAL_TAG 0x10
  45.  
  46. #define    IS_ORIGINAL_VRTX(Vrtx)    ((Vrtx)->Tags & ORIGINAL_TAG)
  47. #define    SET_ORIGINAL_VRTX(Vrtx)    ((Vrtx)->Tags |= ORIGINAL_TAG)
  48. #define    RST_ORIGINAL_VRTX(Vrtx)    ((Vrtx)->Tags &= ~ORIGINAL_TAG)
  49.  
  50.  
  51. /* The following are temporary flags used to mark the polygons in the         */
  52. /* adjacencies propagation. Can use bit 4-7 of IPPolygonStruct Tags only.      */
  53. #define COMPLETE_TAG   0x10 /* Complete Tag - Polygon has no intersection.   */
  54. #define IN_OUTPUT_TAG  0x20 /* InOutput Tag - Polygon should be in output.   */
  55. #define ADJ_PUSHED_TAG 0x40 /* AdjPushed Tag - Polygon has been pushed.         */
  56. #define COPLANAR_TAG   0x80 /* Set if this poly found coplanar in boolean.   */
  57.  
  58. #define    IS_COMPLETE_POLY(Poly)        ((Poly)->Tags & COMPLETE_TAG)
  59. #define    SET_COMPLETE_POLY(Poly)        ((Poly)->Tags |= COMPLETE_TAG)
  60. #define    RST_COMPLETE_POLY(Poly)        ((Poly)->Tags &= ~COMPLETE_TAG)
  61. #define    IS_INOUTPUT_POLY(Poly)        ((Poly)->Tags & IN_OUTPUT_TAG)
  62. #define    SET_INOUTPUT_POLY(Poly)        ((Poly)->Tags |= IN_OUTPUT_TAG)
  63. #define    RST_INOUTPUT_POLY(Poly)        ((Poly)->Tags &= ~IN_OUTPUT_TAG)
  64. #define    IS_ADJPUSHED_POLY(Poly)        ((Poly)->Tags & ADJ_PUSHED_TAG)
  65. #define    SET_ADJPUSHED_POLY(Poly)    ((Poly)->Tags |= ADJ_PUSHED_TAG)
  66. #define    RST_ADJPUSHED_POLY(Poly)    ((Poly)->Tags &= ~ADJ_PUSHED_TAG)
  67. #define    IS_COPLANAR_POLY(Poly)        ((Poly)->Tags & COPLANAR_TAG)
  68. #define    SET_COPLANAR_POLY(Poly)        ((Poly)->Tags |= COPLANAR_TAG)
  69. #define    RST_COPLANAR_POLY(Poly)        ((Poly)->Tags &= ~COPLANAR_TAG)
  70.  
  71. #define ADJ_STACK_SIZE    16386        /* Adjacency of polygons stack size. */
  72.  
  73. /* FatalError types are defined below. Usually, they will cause empty result.*/
  74. #define FTL_BOOL_NO_INTER    1    /* No intersection between operands. */
  75. #define FTL_BOOL_CTRL_BRK    2           /* Control break was pressed. */
  76. #define FTL_BOOL_FPE        3            /* Floating point error. */
  77.  
  78. #ifdef DOUBLE
  79. #define BOOL_EPSILON        1e-10
  80. #else
  81. #define BOOL_EPSILON        1e-6
  82. #endif /* DOUBLE */
  83. #define BOOL_APX_EQ(x, y)        (ABS((x) - (y)) < BOOL_EPSILON)
  84. #define BOOL_PT_APX_EQ(Pt1, Pt2)    (BOOL_APX_EQ(Pt1[0], Pt2[0]) && \
  85.                      BOOL_APX_EQ(Pt1[1], Pt2[1]) && \
  86.                      BOOL_APX_EQ(Pt1[2], Pt2[2]))
  87.  
  88. extern int
  89.      BoolHandleCoplanarPoly,            /* Whether to handle coplanar polys. */
  90.      BoolOutputInterCurve;        /* Kind of output from Boolean oper. */
  91.  
  92. /* Prototypes of local functions in Bool-Hi.c module: */
  93. void FatalBooleanError(int ErrorType);
  94.  
  95. /* Prototypes of local functions in Bool-Low.c module: */
  96. IPObjectStruct *BooleanLow1Out2(IPObjectStruct *PObj1, IPObjectStruct *PObj2);
  97. IPObjectStruct *BooleanLow1In2(IPObjectStruct *PObj1, IPObjectStruct *PObj2);
  98. void BoolSortOpenInterList(IPPolygonStruct *Pl, InterSegListStruct **POpen);
  99. void BoolLoopsFromInterList(IPPolygonStruct *Pl,
  100.                 InterSegListStruct **PlClosed,
  101.                 InterSegListStruct **PlOpen);
  102. IPObjectStruct *BoolExtractPolygons(IPObjectStruct *PObj, int AinB);
  103. int BoolVerifyShareEdge(IPVertexStruct *V, IPPolygonStruct *Pl);
  104.  
  105. #endif /* BOOL_LOC_H */
  106.